/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package ru.example.netcracker.model;

import java.util.List;
import ru.example.netcracker.model.entity.Task;

/**
 *
 * @author Nikolay
 */
public class SynchronizedTaskGroup implements Scheduler {

    public static Scheduler SynchronizedScheduler(Scheduler sch) {
        return new SynchronizedTaskGroup(sch);
    }
    
    private final Scheduler taskGroup;
    
    public SynchronizedTaskGroup(Scheduler taskGroup) {
        this.taskGroup = taskGroup;
    }
    
    @Override
    synchronized public boolean addTask(Task task) {
        return taskGroup.addTask(task);
    }

    @Override
    synchronized public Task getTask(int index) {
        return taskGroup.getTask(index);
    }
    @Override
    synchronized public List<Task> getTasks() {
        return taskGroup.getTasks();
    }

    @Override
    synchronized public boolean removeTask(Task task) {
        return taskGroup.removeTask(task);
    }

    @Override
    synchronized public int size() {
        return taskGroup.size();
    }

    @Override
    public String toString() {
        return "SynchronizedTaskGroup{" + taskGroup.toString() + '}';
    }
    
    
}
